package com.heima.comment.controller.v1;

import com.heima.comment.service.ApCommentService;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentSaveDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: ApCommentController
 * Description:
 * date: 2023/8/28 0028 19:34
 *
 * @author zHan
 */
@RestController
@RequestMapping("/api/v1/comment")
@Api(tags = "用户评论相关接口")
public class ApCommentController {

    @Autowired
    private ApCommentService apCommentService;

    /**
     * 保存评论
     * @param dto
     * @return
     */
    @PostMapping("/save")
    @ApiOperation("保存评论")
    public ResponseResult save(@RequestBody CommentSaveDto dto) {
        return apCommentService.save(dto);
    }

    /**
     * 查询评论列表
     * @param dto
     * @return
     */
    @PostMapping("/load")
    @ApiOperation("查询评论列表")
    public ResponseResult load(@RequestBody CommentDto dto) {
        return apCommentService.load(dto);
    }

    /**
     * 点赞评论
     * @param dto
     * @return
     */
    @PostMapping("/like")
    @ApiOperation("点赞")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return apCommentService.like(dto);
    }

}
